package orm

type Db interface {
	Table(database string) Db
	Field(rows ...string) Db
	Where(key string, condition string, val interface{}, parallel ...string) Db
	Limit(numbers ...string) Db
	Order(row string, sort string) Db
	Join(table string, condition string, parallel ...string) Db
	Group(row string) Db
	Have(condition string) Db
	InsertGetId(add map[string]string) int64
	Insert(add map[string]string) int64
	InsertAll(addAll []map[string]string) int
	Query(sql string) []map[string]string
	Close() error
	Select() []map[string]string
	Find() map[string]string
	Update(renew map[string]string) int64
	Connect(driverName string, dataSourceName string) error
}

func Connect(driverName string, dataSourceName string) Db {
	var m Db
	var err error
	switch driverName {
	case "mysql":
		m = new(Mysql)
		break
	}
	err = m.Connect(driverName, dataSourceName)
	defer SqlErr(err)
	return m
}
